package com.cn.ycy.controller;

import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
@RequestMapping("/log")
@Configuration
public class LogController {

    static final Logger LOGGER = LoggerFactory.getLogger(LogController.class);

    @GetMapping("/get")
    public HashMap<Object, Object> dolog() {
        LOGGER.info("hello word {}", 1);

        HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("1", "2");
        return objectObjectHashMap;
    }

    /**
     * -:代表任务无效
     */
    @Scheduled(cron = "${dataStatistics.cron:0/5 * * * * ?}")
    protected void executeInternal() {
        try {
            System.out.println("working....");
            throw new RuntimeException("抛出一个异常,查看日志");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
